# ------------------------------------- #
# Replication code for:
#
# Pomeroy, Caleb "The Damocles Delusion: The Sense of Power Inflates Threat  
# Perception in World Politics," International Organization.
#
# This script reproduces the supplementary rising versus declining power experiment results from the US.
# ------------------------------------- #


# --- set your working directory --- #
setwd("~/Downloads/damocles_delusion_replication/")

# --- libraries --- #
library(texreg)
set.seed(1912)

# --- load data --- #
qualtrics_df <- readRDS("data/us_rise_decline_data.rds")
dim(qualtrics_df) # the supplementary rise/decline experiment consists of N = 269 US-based respondents recruited from Qualtrics 
qualtrics_df$power_treat <- factor(qualtrics_df$power_treat, levels = c("declining_power", "rising_power")) # subjects' rising versus declining power condition assignment
qualtrics_df$gender <- factor(qualtrics_df$gender, c("non_male", "male")) # self-reported male (versus female or self-describe)
qualtrics_df$ethnicity <- factor(qualtrics_df$ethnicity, c("non_white", "white")) # self-reported white (or non-white) respondent
qualtrics_df$pid <- factor(qualtrics_df$pid, c("non_republican", "republican")) # self-reported party ID, namely whether subject identifies as a republican (or not)
#qualtrics_df$ideology # self-reported political ideology (higher = more conservative)
#qualtrics_df$age # age is on an eight point scale, where 1 = 18-24, 2 = 25-34, 3 = 35-44, 4 = 45-54, 5 = 55-64, 6 = 65-74, 7 = 75-84, 8 = 85 or older
#qualtrics_df$threat_perception # seven-point (dis)agreement with "In international relations, the U.S. faces many security threats" (higher = higher threat perception)

# --- sample demographics --- #
# below are sample demographic stats mentioned in the appendix
table(qualtrics_df$gender)/nrow(qualtrics_df) # 49.4% male
sum(table(qualtrics_df$age)[1:2])/nrow(qualtrics_df) # 33.5% aged 18-34
sum(table(qualtrics_df$age)[3:5])/nrow(qualtrics_df) # 47.2% aged 35-64
sum(table(qualtrics_df$age)[6:8])/nrow(qualtrics_df) # 19.3% aged 65 or older

# --- regression model --- #
# this was a simple experiment that serves as a robustness check on whether rising/declining power experimentally increases threat perception akin to static power comparisons
# this study also provides an experimental (and cross-national) check on the correlational items used in the Russian elite survey, which were dynamic in wording
summary(rise_decline_ols <- lm(threat_perception ~ power_treat + age + gender + ethnicity + pid + ideology, data = qualtrics_df))

# --- appendix table A10
screenreg(rise_decline_ols)
# texreg(rise_decline_ols,
#        booktabs = T,
#        custom.coef.names = c("(Intercept)", "High Power Treatment", "Age", "Male", "White", "Republican", "Conservative"),
#        custom.model.names = "Threat Perception",
#        caption = "US Experiment: OLS Results",
#        caption.above = T,
#        label = "table:rise_decline_ols")

